﻿#include "includes\\InputStructures.fx"
#include "includes\\CommonResources.fx"

float4x4 xWallTransformationMatrix;


struct PsInput_Wall
{
	float4 ScreenPos : SV_POSITION;
	float4 Normal : NORMAL;
	float Height: TEXCOORD1;
};


PsInput_Wall WallVS(VsInput_PN input)
{
	PsInput_Wall output = (PsInput_Wall)0;
	
	output.ScreenPos = mul(mul(input.Pos, xWallTransformationMatrix), xViewProjectionMatrix);
	output.Normal = input.Normal;
	output.Height = mul(input.Pos, xWallTransformationMatrix).y;
	
	return output;
}


float GetIntensityByOrientation(float4 normal)
{
	return 1.1f + 0.2f * normal.x;
}


float4 GetColorByHeight(float height)
{
	return xPlayerColor * saturate(sqrt(height + 0.3)*0.9);
}


float GetAlphaByHeight(float height)
{
	return pow(abs(height - 0.6f) * 1.2, 2) + 0.5f;
}


float4 WallPS(PsInput_Wall input) : SV_Target
{
	float4 wallColor = GetIntensityByOrientation(input.Normal) * GetColorByHeight(input.Height);
	wallColor.a = GetAlphaByHeight(input.Height);

	return wallColor;
}


float4 WallPS_NoAlpha(PsInput_Wall input) : SV_Target
{
	float4 wallColor = GetIntensityByOrientation(input.Normal) * GetColorByHeight(input.Height);
	wallColor.a = 1.0f;

	return wallColor;
}